package com.vlin.converter.defaut;

import java.util.Map;

import org.json.JSONObject;

import com.vlin.converter.DeviceInfoConverter;
import com.vlin.converter.ListDeviceInfoConverter;
import com.vlin.converter.manager.ConverterManager;
import com.vlin.entity.mode.DeviceMode;

public class DefaultDeviceInfoConverter  implements ListDeviceInfoConverter {

	private ConverterManager  convertManager = new DefaultDeviceInfoConverter();

	@Override
	public JSONObject convertToFront(JSONObject params, DeviceMode deviceMode) {
		
		return getConverterManager().getConverter(deviceMode).convertToFront(params, deviceMode);
	}

	@Override
	public JSONObject convertToBack(JSONObject params, DeviceMode deviceMode) {
		
		return getConverterManager().getConverter(deviceMode).convertToBack(params, deviceMode);
	}

	@Override
	public boolean supportDeviceType(DeviceMode deviceMode) {
		
		return support(deviceMode);
	}

	@Override
	public boolean support(DeviceMode deviceMode) {
		
		return getConverterManager().support(deviceMode);
	}

	@Override
	public DeviceInfoConverter getConverter(DeviceMode deviceMode) {
		
		return getConverterManager().getConverter(deviceMode);
	}

	@Override
	public void put(DeviceMode deviceMode, DeviceInfoConverter converter) {
		getConverterManager().put(deviceMode, converter);
	}

	@Override
	public void setConverterMap(Map<DeviceMode, DeviceInfoConverter> map) {
		
		getConverterManager().setConverterMap(map);
		
	}

	@Override
	public ConverterManager getConverterManager() {
		
		return this.convertManager;
	}

	@Override
	public void setConverterManager(ConverterManager converterManager) {
		if(converterManager != null) {
			this.convertManager = converterManager;
		}	
	} 


}
